<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>评估准则构建展示</title>
	<meta name="description" content="评估准则构建软件">
	<!-- Bootstrap CSS -->
	<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
	<!-- 字体CSS -->
	<link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
	<link href="assets/css/bootstrap-select/bootstrap-select.css" rel="stylesheet" type="text/css" />
	<!-- 自定义样式 -->
	<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="./assets/layui/css/layui.css">
	<link rel="stylesheet" href="./assets/css/norm/normEdit.css">
	<style>

	</style>
</head>

<body class="adminbody">
<div id="main">
	<!-- 头部导航 -->
	<div class="headerbar">
		<!-- LOGO -->
		<div class="headerbar-left">
			<a href="index.html" class="logo">
				<!--					<img alt="Logo" src="assets/images/logo.png" />-->
				<span>评估准则构建软件</span>
			</a>
		</div>

		<nav class="navbar-custom">
			<ul class="list-inline float-right mb-0">
				<li class="list-inline-item dropdown notif">
					<a class="nav-link dropdown-toggle arrow-none" data-toggle="dropdown" href="#" role="button"
					   aria-haspopup="false" aria-expanded="false">
						<i class="fa fa-fw fa-bell-o"></i><span class="notif-bullet"></span>
					</a>
					<div class="dropdown-menu dropdown-menu-right dropdown-arrow dropdown-lg">
						<!-- item-->
						<div class="dropdown-item noti-title">
							<h5><small><span class="label label-danger pull-xs-right">1</span>消息提醒</small></h5>
						</div>
						<!-- item-->
						<a href="#" class="dropdown-item notify-item">
							<div class="notify-icon bg-faded">
								<img src="assets/images/avatars/avatar2.png" alt="img"
									 class="rounded-circle img-fluid">
							</div>
							<p class="notify-details">
								<b>Admin</b>
								<span>用户信息注册成功</span>
								<small class="text-muted">3分钟前</small>
							</p>
						</a>
						<!-- All-->
						<a href="#" class="dropdown-item notify-item notify-all">
							查看所有消息
						</a>

					</div>
				</li>

				<li class="list-inline-item dropdown notif">
					<a class="nav-link dropdown-toggle nav-user" data-toggle="dropdown" href="#" role="button"
					   aria-haspopup="false" aria-expanded="false">
						<img src="assets/images/avatar.jpg" alt="Profile image" class="avatar-rounded">
					</a>
					<div class="dropdown-menu dropdown-menu-right profile-dropdown ">
						<!-- item-->
						<div class="dropdown-item noti-title">
							<h5 class="text-overflow"><small>Hello, admin</small> </h5>
						</div>

						<!-- item-->
						<a href="pro-profile.html" class="dropdown-item notify-item">
							<i class="fa fa-user"></i> <span>个人中心</span>
						</a>

						<!-- item-->
						<a href="#" class="dropdown-item notify-item">
							<i class="fa fa-power-off"></i> <span>退出</span>
						</a>
					</div>
				</li>

			</ul>

			<ul class="list-inline menu-left mb-0">
				<li class="float-left">
					<button class="button-menu-mobile open-left">
						<i class="fa fa-fw fa-bars"></i>
					</button>
				</li>
			</ul>

		</nav>

	</div>
	<!-- 头部导航End -->
	<!-- 左侧导航开始 start-->
	<div class="left main-sidebar">
		<div class="sidebar-inner leftscroll">
			<div id="sidebar-menu">
				<ul>
					<li class="submenu">
						<a href="index.html"><i class="fa fa-fw fa-home"></i><span>评估准则首页</span> </a>
					</li>
					<li class="submenu">
						<a href="normCreate.html" ><i class="fa fa-fw fa-check-circle-o"></i><span>评估准则生成</span> </a>
					</li>
					<li class="submenu">
						<a href="normEdit.html" class="active"><i class="fa fa-fw fa-pencil-square-o"></i><span>评估准则编辑</span> </a>
					</li>
					<li class="submenu">
						<a href="normEdit.html"><i class="fa fa-fw fa-bars"></i><span>评估准则展示</span> </a>
					</li>
					<li class="submenu">
						<a href="normTemplete.html"><i class="fa fa-fw fa-file-text-o"></i><span>评估准则模板</span> </a>
					</li>
				</ul>
				<div class="clearfix"></div>
			</div>
			<div class="clearfix"></div>

		</div>
	</div>
	<!-- End 左侧导航 -->
	<div class="content-page">
		<div class="norm-switch">
			<form class="layui-form" action="">
				<div class="layui-form-item">
					<label class="layui-form-label" style="width:120px;">图形展示：</label>
					<div class="layui-input-block">
						<input type="checkbox" name="zzz" lay-skin="switch" lay-text="开启|关闭" lay-filter="dataSwitch">
					</div>
				</div>
			</form>
		</div>
		<!-- Start content -->
		<!-- 数据表 -->
		<div class="content table-content">
            <iframe src="./normChart.html" frameborder="0" scrolling ='no' id="normChart" style="display: none;"></iframe>
			<table class="layui-hide" id="test" lay-filter="test"></table>
		</div>
	</div>
</div>
<!-- 左边工具栏 -->
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<div class="table-tool-left">

		</div>
		<div class="table-tool-right tool-bar">
			<button class="layui-btn " lay-event="getDeleteData" >
				<i class="fa fa-fw fa-trash-o"></i>
			</button>
			<button class="layui-btn" lay-event="getOutputData" >
				<i class="fa fa-fw fa-download"></i>
			</button>
		</div>

	</div>
</script>
<!-- 右边工具栏 -->
<script type="text/html" id="barDemo">
	<a class="layui-btn layui-btn-xs" lay-event="edit" style="color:#fff;">编辑</a>
</script>



<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script src="assets/js/modernizr.min.js"></script>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/moment.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>


<script src="assets/js/detect.js"></script>
<script src="assets/js/fastclick.js"></script>
<script src="assets/js/jquery.blockUI.js"></script>
<script src="assets/js/jquery.nicescroll.js"></script>
<script src="assets/js/bootstrap-select/bootstrap-select.js"></script>

<!-- App js -->
<script src="assets/js/pikeadmin.js"></script>
<script src="./assets/layui/layui.js"></script>

<script>
	var dateRange=``,paramArr=["name","type","number","unit","forces","inParam","outParam","stateInfo","useAddr"],editId;
	var layer;
	layui.use('layer', function(){
		layer=layui.layer;
	});
	layui.use(['form'], function () {
		var form = layui.form;
		//图形切换
		form.on('switch(dataSwitch)', function(data){
			console.log(data.elem); //得到checkbox原始DOM对象
			console.log(data.elem.checked); //开关是否开启，true或者false
			console.log(data.value); //开关value值，也可以通过data.elem.value得到
			console.log(data.othis); //得到美化后的DOM对象
            var checkd=data.elem.checked;
            if (checkd){
                $('.table-content>table').css({display:'none'});
                $('#normChart').css({display:'block'});
                $('.table-content>.layui-table-view').css({display:'none'});
                $('.content-page .content').css({padding:0,marginTop:'-30px'})
            }else {
                $('#normChart').css({display:'none'});
                $('.table-content>table').css({display:'block'});
                $('.table-content>.layui-table-view').css({display:'block'});
                $('.content-page .content').css({padding:'15px 5px 0px 5px',margin:15})
            }
		})
	});
	// 数据表格
	layui.use('table', function(){
		var table = layui.table;
		table.render({
			elem: '#test',
			url:'/bs/standardManage/getStandardPage',
			method:'post'
			//,contentType: 'application/json'
			// ,where:{currentPage:1, pageSize: 3}
			,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
			,defaultToolbar: []
			,title: '用户数据表'
			,cols: [[
				{type: 'checkbox', fixed: 'left'}
				// ,{field:'id', title:'ID',  fixed: 'left', width:60,unresize: true,align:'center'}
				,{field:'sort', title:'序号', width:60,unresize: true,align:'center',type:'numbers'}
				,{field:'standardName', title:'准则名称',align:'center' }
				,{field:'context', title:'评估内容',align:'center'}
				,{field:'method', title:'评估指标',align:'center'}
				,{field:'target', title:'评估对象',align:'center'}
				,{field:'category', title:'准则类别',align:'center'}
				,{field:'creater', title:'创建人',align:'center'}
				,{field:'createTime', title:'创建时间',align:'center'}
				,{field:'frequency', title:'使用次数',align:'center'}
				,{fixed: 'right', title:'操作', toolbar: '#barDemo',align:'center'}
			]]
			,page: {
				layout: [ 'prev', 'page', 'next', 'count','limit',  'skip']//自定义分页布局
				,limit:10
				// ,limits:[10,20,30]
				,first: false //不显示首页
				,last: false //不显示尾页
			}
			,request: {
				pageName: 'currentPage' //页码的参数名称，默认：page
				,limitName: 'pageSize' //每页数据量的参数名，默认：limit
			}
			,parseData: function(res){ //res 即为原始返回的数据
				return {
					"code": res.status, //解析接口状态
					"msg": res.msg, //解析提示文本
					"count": res.data.totalCount, //解析数据长度
					"data": res.data.lists //解析数据列表
				};
			}
	});
		//头工具栏事件
		table.on('toolbar(test)', function(obj){
			var checkStatus = table.checkStatus(obj.config.id);
			var checkData = checkStatus.data,checkArr=[];
			console.log(checkData)
			//数据id 获取
			if (checkData.length>0){
				for (let i of  checkData){
					checkArr.push(i.id);
				}
			}
			//工具栏
			switch(obj.event){
				case 'getOutputData':
					layer.open({
						type: 1 //Page层类型
						,area: ['400px', '200px']
						,title: `<p style="font-size: 18px;">请选择文件下载类型？</p>`
						,shade: 0.6 //遮罩透明度
						,anim: 1 //0-6的动画形式，-1不开启
						,content:
								`
								<div class="layui-row" style="margin-top: 40px;">
									<div class="layui-col-xs4">
										<button type="button" class="layui-btn" onclick="fileDownload('xml')" style="margin-left: 20px;">
											XML文件
										</button>
									</div>
									<div class="layui-col-xs4">
										<button type="button" class="layui-btn" onclick="fileDownload('excel')" style="margin-left: 15px;">
											Excel文件
										</button>
									</div>
									<div class="layui-col-xs4">
										<button type="button" class="layui-btn" onclick="fileDownload('word')" style="margin-left: 15px;">
											Word文件
										</button>
									</div>
								</div>
								`
					});
					break;
				case 'getDeleteData':
					if (checkArr.length>0){
						layer.confirm('确认要删除吗？', {
							btn: ['确认','取消'] //按钮
						}, function(){
							$.ajax({
								//请求方式
								type : "POST",
								//请求的媒体类型
								contentType: "application/x-www-form-urlencoded",
								//请求地址
								url : "/bs/standardManage/deleteStandard",
								//数据，json字符串
								data : {ids:checkArr.join(',')},
								//请求成功
								success : function(res) {
									if (res.status==0){
										layer.msg('删除成功！',{time:2000});
										//刷新数据
										$(".layui-laypage-btn")[0].click();
									}else {
										layer.msg('删除失败！',{time:2000});
									}
								},
								//请求失败，包含具体的错误信息
								error : function(e){
									console.error(e.status);
									console.error(e.responseText);
								}
							});
						});
					}
					break;
			};
		});

		//监听行工具事件
		table.on('tool(test)', function(obj){
			var data = obj.data;
			if(obj.event === 'edit'){
				handleEdit(data);
				editId=data.id;
			}
		});
	});
//	编辑
    function handleEdit(data){
        layer.open({
            type: 1 //Page层类型
            ,area: ['1400px', '700px']
            ,title: false
            ,shade: 0.4 //遮罩透明度
            ,maxmin: false //允许全屏最小化
            ,anim: 1 //0-6的动画形式，-1不开启
            ,content:`<iframe src="./normModule.html" frameborder="0" scrolling ='no' id="normIframe"></iframe>`
            ,success: function(layer, index){
				var normIframe=document.getElementById("normIframe");
				normIframe.onload=function (){
					normIframe.contentWindow.fillVal(data);
					normIframe.contentWindow.postType('normEdit');
				}
            }
        });
    }
//    文件下载
	function fileDownload(type) {
		var a=document.createElement('a');
		a.setAttribute('download', '');// download属性
    	if (type=='xml'){
			a.setAttribute('href', '/bs/standardManage/exportXml');// href链接
		}else if (type=='excel'){
			a.setAttribute('href', '/bs/standardManage/exportExcel');// href链接
		}else if (type=='word'){
			a.setAttribute('href', '/bs/standardManage/exportWord');// href链接
		}
		a.click();
	}
//    修改提交
	function getInfo(obj,check) {
    	var data=Object.assign(obj,{id:editId})
		$.ajax({
			//请求方式
			type : "POST",
			//请求的媒体类型
			contentType: "application/x-www-form-urlencoded",
			//请求地址
			url : "/bs/standardManage/updateStandard",
			//数据
			data : data,
			//请求成功
			success : function(res) {
				console.log(res);
				if (res.status==0){
					layer.closeAll();
					layer.msg('修改成功！',{time:2000});
					//刷新数据
					$(".layui-laypage-btn")[0].click();

				}else {
					layer.msg('修改失败！',{time:2000});
				}
			},
			//请求失败，包含具体的错误信息
			error : function(e){
				console.error(e.status);
				console.error(e.responseText);
			}
		});
	}
</script>
</body>

</html>